import request from "@/request/request";

export const startSubmit = ({ chartType, goal, name }: { chartType: string; goal: string; name: string }, file: File | null) => {
  // 创建 FormData 对象
  const formData = new FormData();

  // 添加文本字段
  formData.append('chartType', chartType);
  formData.append('goal', goal);
  formData.append('name', name);

  // 如果有文件，则添加文件
  if (file) {
    formData.append('file', file);
  }

  // 发送 POST 请求
  return request.post('/api/chart/gen/async', formData);
};

export const getChartList = ({chartType, current, goal, id, name, pageSize, sortFiled, sortOrder, userId}: any) => {
  return request.post('/api/chart/my/list/page',
    {
      chartType,
      current,
      goal,
      id,
      name,
      pageSize,
      sortFiled,
      sortOrder,
      userId
    })
}
